package com.xxx.String;

/**
 * @version v1.0
 * @Description
 * @Author admin
 * @date 2021/7/19  10:23
 * @Copyright
 */
public class StringDome02 {
    public static void main(String[] args) {
        /*
         * 查：String底层数据结构是字符数组
         * */
        String s = "abcdefghlmn";
        System.out.println(s.length());//长度
        System.out.println(s.charAt(3));//根据下标返回对应的字符
        System.out.println(s.indexOf("d"));//根据字符返回对应的下标，如果没有找到返回-1，如果有多个返回第一个字符对应的下标
        System.out.println(s.lastIndexOf("d"));//
        System.out.println(s.substring(3, 6));//包含头部，不包含尾部
        System.out.println(s.substring(3));

        String s1 = "acnbaskcskjfhwkdfnwnl";
        String s2 = "dh";
        int count = 0;
        int index = 0;
        while ((index = s1.indexOf(s2)) != -1) {
            s1 = s1.substring(index + s2.length());

        }


    }
}
